//
//  YYJLLevelCell.m
//  YuanyangJinlou
//
//  Created by mac004 on 2017/1/5.
//  Copyright © 2017年 suli19910309@qq.com. All rights reserved.
//

#import "YYJLLevelCell.h"

@implementation YYJLLevelCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self creatUI];
    }return  self;
}
- (void)setRuleArr:(NSArray *)ruleArr
{
    _ruleArr = ruleArr;
    [self creatUI];
}



- (void)creatUI
{
    NSString* first =_ruleArr[0];
    
    NSString * second = _ruleArr[1];
    if (first.length>2) {
        
        UILabel * lab1=[MyControl createLabelWithFrame:CGRectMake(0, 13*PER_HEIGHT, 175*PER_WIDTH, 14*PER_HEIGHT) Font:14 Text:first Color:WHITE_COLOR];
        lab1.textAlignment=NSTextAlignmentCenter;
        [self.contentView addSubview:lab1];
    }else{
        UIImage*img=[UIImage imageNamed:first];
        UIImageView * level =[[UIImageView alloc]initWithFrame:CGRectMake(175*PER_WIDTH/2-img.size.width*PER_WIDTH/2, 12*PER_HEIGHT, img.size.width*PER_WIDTH, img.size.height*PER_HEIGHT)];
        level.image=img;
        [self.contentView addSubview:level];
    }
    for (int i = 0; i<3; i++) {
        UIView * line1 = [[UIView alloc]initWithFrame:CGRectMake(i*175*PER_WIDTH, 0, 0.5, 38*PER_HEIGHT)];
        if (first.length>2) {
            line1.height=40*PER_HEIGHT;
            
        }
        line1.backgroundColor=UIColorFromHex(0xcccccc);
        [self.contentView addSubview:line1];

    }
    
    UILabel * lab2=[MyControl createLabelWithFrame:CGRectMake(176*PER_WIDTH, 13*PER_WIDTH, 175*PER_WIDTH, 14) Font:14 Text:second Color:WHITE_COLOR];
    lab2.textAlignment=NSTextAlignmentCenter;
    if (first.length<2|first.length==2) {
        lab2.font=[UIFont fontWithName:HLT size:12];
        lab2.textColor=FEELT_COLOR;
        lab2.height=12*PER_HEIGHT;
    }
    [self.contentView addSubview:lab2];
    
    UIView* line2 =[[UIView alloc]initWithFrame:CGRectMake(0, 38*PER_HEIGHT-0.5, self.width, 0.5)];
   
    line2.backgroundColor=UIColorFromHex(0xcccccc);
    if (first.length>2) {
        return;
    }
    [self.contentView addSubview:line2];
}

@end
